import java.util.Scanner;

public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String a = scanner.next();
        String b = scanner.next();
        int i = 0;
        int j = 0;
        boolean flag = false;
        while (i < a.length() && j < b.length()) {
            char ch1 = a.charAt(i);
            char ch2 = b.charAt(j);
            if (ch1 == '?') {
                if (ch2 == '#') {
                    flag = true;
                    break;
                }
                i++;
                j++;
                continue;
            }
            if (ch1 == '*') {
                while (ch1 == '*' && i < a.length()) {
                    i++;
                    if (i < a.length()) {
                        ch1 = a.charAt(i);
                    }
                }
                if (ch1 == '?') {
                    if (ch2 == '#') {
                        flag = true;
                        break;
                    }
                    i++;
                    j++;
                    continue;
                }
                while (ch1 != ch2 && ch1 != ch2 + ('a' - 'A') && ch1 != ch2 - ('a' - 'A') && j < b.length()) {
                    j++;
                    if (j < b.length()) {
                        ch2 = b.charAt(j);
                    }
                }
            }
            if ((ch1 != ch2 && ch1 != ch2 + ('a' - 'A') && ch1 != ch2 - ('a' - 'A')) || ch2 == '#') {
                flag = true;
                break;
            }
            i++;
            j++;
        }
        System.out.println(!flag);
    }
}
